package org.iba.coobob;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast;

public class Charge extends Activity {

	private RadioGroup radioGroup;
	private Button chargeOK;
	private int option;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_charge);

		radioGroup = (RadioGroup)findViewById(R.id.radioGroup);
		chargeOK = (Button)findViewById(R.id.chargeOK);
		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub

				if(checkedId==R.id.radioButton1)
				{
					option = 10000;
				}
				else if(checkedId==R.id.radioButton2)
				{
					option = 20000;
				}
				else if(checkedId==R.id.radioButton3)
				{
					option = 30000;
				}
				else if(checkedId==R.id.radioButton4)
				{
					option = 40000;
				}
				else if(checkedId==R.id.radioButton5)
				{
					option = 50000;
				}
				else
					option = 0;

			}
		});

		chargeOK.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Builder alert = new AlertDialog.Builder(Charge.this);
				alert.setTitle("결제 확인");
				alert.setMessage(option+"원을 충전 하시겠습니까?");
				alert.setPositiveButton("확인", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						Toast.makeText(Charge.this, ""+option, Toast.LENGTH_SHORT).show();
					}
				});
				alert.setNegativeButton("취소", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						Toast.makeText(Charge.this, "취소되었습니다.", Toast.LENGTH_SHORT).show();
					}

				});
				alert.show();
			}
		});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.charge, menu);
		return true;
	}

}
